﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using CrystalCore;
using CrystalCore.Actors;
using CrystalCore.Mapping;
using Microsoft.Xna.Framework;

namespace CrystalCore.Structure
{
    public static class CellFactory
    {
        public static T CreateInstance<T>(MazePosition position)
            where T : CellBase
        {
            ConstructorInfo cinfo = typeof(T).GetConstructor(new Type[] { typeof(MazePosition) });

            if(cinfo == null)
                throw new CrystalCoreFrameworkError(CrystalCoreErrors.DynamicFactoryError);

            return (T)cinfo.Invoke(new object[] { position });
        }
    }

    public static class ElementalFactory
    {
        public static T CreateInstance<T>(MazePosition position)
            where T : Elemental
        {
            ConstructorInfo cinfo = typeof(T).GetConstructor(new Type[] { typeof(MazePosition) });

            if (cinfo == null)
                throw new CrystalCoreFrameworkError(CrystalCoreErrors.DynamicFactoryError);

            return (T)cinfo.Invoke(new object[] { position });
        }
    }
}
